const ipconfig = require('../ipconfig');
const mysql = require('mysql');
const config = {
  host:ipconfig.ip,
  user:'admin',
  password:'admin666',
  database:'mrbyte'
}
const pool = mysql.createPool(config);
const query = (sql)=>{
  return new Promise((resolve, reject) => {
    pool.getConnection((err, conn) => {
      if (err) {
        reject(err)
      } else {
        conn.query(sql, (error, response) => {
          if (error) {
            reject(error)
          } else {
            resolve(response)
          }
        });
        conn.release();
      }
    })
  });
}
module.exports = query;
